class Usuario < ActiveRecord::Base
  # Include default devise modules. Others available are:
  # :token_authenticatable, :encryptable, :confirmable, :lockable, :timeoutable and :omniauthable
  devise :database_authenticatable, :registerable, :rememberable, :validatable

  # Setup accessible (or protected) attributes for your model
  attr_accessible :email, :senha, :password, :nome, :cpf, :telefone, :rua, :numero, :bairro, :cidade, :estado, :pais, :remember_me
  
	
	validates :nome,    :presence => true
    validates :senha,   :presence => true,
						:length => { :minimum => 8 }
	validates :email,   :presence => true
	validates :cpf,  	:presence => true
	validates :telefone,:presence => true
	validates :rua,  	:presence => true
	validates :numero,  :presence => true
	validates :bairro,  :presence => true
	validates :cidade,  :presence => true
	validates :estado,  :presence => true
	validates :pais,  	:presence => true
	has_many:contratos, :dependent => :destroy
  
  def encrypted_password
    self[:PasswordSHA1Hash]
  end 
  
  def encrypted_password=(encrypted_password)
    self[:PasswordSHA1Hash] = encrypted_password
  end
  
end
